package com.example.runningdemo.designModel.factory.simple;

import cn.hutool.core.util.StrUtil;

/**
 * @program: Running-Demo
 * @description: 水工厂
 * @author: kangwei
 * @create: 2024-08-09 08:21
 **/

public class WaterFactory {

    /**
     * 获取水产品名称
     * 此方式后续若水产品分类越来越多时，不利于维护
     *
     * @param name
     * @return
     */
    public static Water getWaterName(String name) {
        if ("纯净水".equals(name)) {
            return new ClearWater();
        }
        if ("引用水".equals(name)) {
            return new DrinkingWater();
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(getWaterName("纯净水"));
        System.out.println(getWaterName("引用水"));
    }
}
